
%Image Processing Assignment - 2
%Name: - Kirtish Dhande
%Class: - B.E. - C
%Roll no: - 54
% This is the program for intensity slicing of a grayscale image.
%Date of assignment - 19/01/2016

%Variables declared -
% A - used to access original image.
% R1 - used to work on resultant/final image.
% C1 - one of the colors used to fill an intensity.
% C2 - one of the colors used to fill an intensity.
% B - will store all the colors w.r.t. different intensities.

clc;
clear all;
close all;

%This stores the pixel values of images in A.
A = imread('earth1.tif');

%Displays the image in A.
imshow(A)
title('Original Image');

%Colors we choose to give to different intensities.
C1 = [0 0 255];
C2 = [0 255 0];

%To flip the image we need the size of the image first.
[m,n]= size(A);

%Convert and store values as double in A1.
A = double(A);

B = zeros(300,300,3);

for i = 1 : m
    for j = 1 : n
        if ( A(i,j) >= 50 && A(i,j) < 100)
            B(i,j,1) = uint8(C1(1));
            B(i,j,2) = uint8(C1(2));
            B(i,j,3) = uint8(C1(3));
        elseif ( A(i,j) > 100 && A(i,j) <= 200)
            B(i,j,1) = C2(1);
            B(i,j,2) = C2(2);
            B(i,j,3) = C2(3);
        end
    end
end
    % We store the resultant color intensity values in resultant array.
    R1(:,:,1) = uint8(B(:,:,1));
    R1(:,:,2) = uint8(B(:,:,2));
    R1(:,:,3) = uint8(B(:,:,3));

%Displays the image in A1 as well as previous image A.
figure, imshow(uint8(R1));
title('Final Image');
   